// ----------------------------------------
// Filename: configuration.h
// Description: The header file for micro RTOS's timers
// Author: Jon Maloney
// Date: 8-Jun-2012
//

#ifndef TIMER_H
#define TIMER_H

//************************************************************
//                    Include .h files
//************************************************************
#include "microRTOS.h"
#include "Thread.h"
#include "types.h"
//************************************************************
//                    Include external references
//************************************************************

//************************************************************
//                    Define Statements
//************************************************************
#define _UNIT_DELETE		0
#define _UNIT_MICRO_SECONDS	1
#define _UNIT_MILLI_SECONDS 2
#define _UNIT_SECONDS		3
#define _UNIT_MINUTES		4
#define _UNIT_HOURS			5
#define _UNIT_DAY			6
#define _UNIT_YEAR			7

#define _FREQUENCY 	s.PeriodOrFrequency
#define _PERIOD		s.PeriodOrFrequency
#define _UNITS		s.Units

#define	   	MicroSecondsInMilliSeconds	1000
#define 	MilliSecondsInSeconds		1000
#define    	SecondsInMinutes           	60
#define    	MinutesInHour              	60
#define    	HourInDay                  	24
#define    	MonthInYear                	12
#define 	DaysInYear					365

static const UINT8    Feburary                   = 2;

//************************************************************
//                    Struct, Union, enum Statements
//************************************************************
typedef union
{
	UINT16 timeout;
	struct
	{
		unsigned Units					:3;	//Unit the sample periodOrFrequency is measured in.
														//		000 = 		Delete Frequency
														//		001 = us	(micro seconds)
														//		010 = ms 	(milli seconds)
														//		011 = s		(seconds)
														//		100 = m 	(minutes)
														//		101 = h		(hour)
														//		110 = d		(Day)
														//		111	= Y		(Year)
		unsigned PeriodOrFrequency		:10; //The sampling frequency or sampling period of the signal
		unsigned						:3;	//Reserved
	}s;
}T_TIMER_RATE;

//************************************************************
//                    Global variables and constants
//************************************************************

static const UINT16 DT_C_Array[6] = {	MicroSecondsInMilliSeconds, 
										MilliSecondsInSeconds, 
										SecondsInMinutes, 
										MinutesInHour, 
										HourInDay,
										DaysInYear};


//************************************************************
//                    Prototype Global Functions
//************************************************************

void Timer_SetupTickTimerInterrupt( void );
UINT16 Timer_SetupTimer3( T_TIMER_RATE * t_Rate, void *callOnTimeOut );

#endif
